#ifndef C_GENERATE_C__
#define C_GENERATE_C__

#include <string.h>

#include "generate-imports.h"
#include "generate-declarations.h"

#if 0
import std.string;
#endif

char* c$generate(struct Module* ast)
{
	if(ast == NULL) return NULL;

	char* imports = c$generateImportList(ast->imports);

	if(imports == NULL) return c$generateDeclarationList(ast->declarations);

	char* declarations = c$generateDeclarationList(ast->declarations);

	char* r = malloc(strlen(imports) + strlen(declarations) + 1);
	strcpy(r,imports);
	strcat(r,declarations);

	return r;
}

#endif
